<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('文件上传')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-task-edit" class="form-horizontal" th:object="${task}">
        <input id="taskId" type="hidden" name="taskId" th:field="*{taskId}"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span style="color: red; ">*</span>任务标题：</label>
                    <div class="col-sm-10">
                        <input class="form-control" type="text" maxlength="30" th:field="*{taskTitle}"
                               th:readonly="true">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group draggable">
            <label class="col-sm-2 control-label">紧急程度：
            </label>

            <div class="col-sm-10">
                <label class="radio-box"><input type="radio" value="普通" th:field="*{taskPriority}">普通</label>
                <label class="radio-box"><input type="radio" value="紧急" th:field="*{taskPriority}">紧急</label>
                <label class="radio-box"><input type="radio" value="非常紧急" th:field="*{taskPriority}">非常紧急</label>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">开始日期：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input type="datetime-local" class="form-control" step="1" th:readonly="true"
                                   th:value="${#dates.format(task.taskStartTime,'yyyy-MM-dd')}+'T'+${#dates.format(task.taskStartTime,'HH:mm:ss')}">
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">截止日期：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input type="datetime-local" class="form-control" step="1" th:readonly="true"
                                   th:value="${#dates.format(task.taskEndTime,'yyyy-MM-dd')}+'T'+${#dates.format(task.taskEndTime,'HH:mm:ss')}">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">创建时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input type="datetime-local" class="form-control" step="1" th:readonly="true"
                                   th:value="${#dates.format(task.taskCreateTime,'yyyy-MM-dd')}+'T'+${#dates.format(task.taskCreateTime,'HH:mm:ss')}">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span style="color: red; ">*</span>执行人员：</label>
                    <div class="col-sm-10">
                        <input class="form-control" type="text" maxlength="30" th:field="*{executorCrew.crewName}"
                               th:readonly="true">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">任务内容：</label>
                    <div class="col-xs-10">
                        <textarea maxlength="500" class="form-control" rows="3" th:field="*{taskContent}"
                                  th:readonly="true"></textarea>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">其他信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">任务状态：</label>
                    <div class="col-sm-8">
                        <select class="form-control" name="taskStatus">
                            <option value="0">未完成</option>
                            <option value="1">完成</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">工作成果描述：</label>
                    <div class="col-xs-10">
                        <textarea name="taskResultDesc" maxlength="500" class="form-control" rows="3"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="form-group">
                        <label class="font-noraml">附件上传</label>
                        <div class="file-loading">
                            <input id="fileinput-demo-1" type="file" name="uploadFile">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>

<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: select2-js"/>
<script>
    var prefix = ctx + "hcy/task/taskmanager";

    $(document).ready(function () {
        $("#fileinput-demo-1").fileinput({
            'theme': 'explorer-fas',
            'uploadUrl': '/task/fileUpload/uploadFile',
            overwriteInitial: false,
            maxFileCount: 1,
            initialPreviewAsData: true,
            uploadExtraData: function () {//向后台传递参数
                var data = {
                    taskId: $("#taskId").val()
                };
                return data;
            },
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-task-edit").serializeArray();
            $.operate.saveTab(prefix + "/submit", data);
        }
    }
</script>
</body>
</html>